import { TGuildStructureConfig } from "../../../Message/Db/Tables/TGuildStructureConfig";
import { ConfigManager } from "../../../com/gengine/resource/ConfigManager";
import { EGuildStructureType } from "../../../Message/Public/EGuildStructureType";
type int = number;
//class GuildStructureConfig
    
    export  class GuildStructureConfig
    {
        constructor()
        {
            
            this._map = new Map<any, any> /* flash.utils.Dictionary */();
            this._configArray = [];
            if (GuildStructureConfig._instance != null) 
            {
                throw new Error(" GuildStructureConfig 单例 ");
            }
            this.init();
            return;
        }

        /* internal  */write(arg1: Object): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            var loc4=arg1;
            for(loc2 of loc4) 
            {
                loc1 = new TGuildStructureConfig();
                loc1.structure = loc2.structure;
                loc1.level = loc2.level;
                loc1.needMoney = loc2.needMoney;
                loc1.needResource = loc2.needResource;
                loc1.needBloom = loc2.needBloom;
                loc1.preStructure = loc2.preStructure;
                loc1.preLevel = loc2.preLevel;
                loc1.needTime = loc2.needTime;
                loc1.effect = loc2.effect;
                this._map[loc1.structure + "-" + loc1.level] = loc1;
                this._configArray.push(loc1);
            }
            return;
        }

        public init(): void
        {
            var loc1=ConfigManager.instance.getJSONByFileName("t_guild_structure_config.json");
            this.write(loc1);
            return;
        }

        public getInfoByType(arg1: int, arg2: int): TGuildStructureConfig
        {
            return this._map[arg1 + "-" + arg2];
        }

        public getMaxLevelByType(arg1: int): int
        {
            var loc1=0;
            var loc2=null;
            var loc3=0;
            while (loc3 < this._configArray.length) 
            {
                loc2 = this._configArray[loc3] as TGuildStructureConfig;
                if (loc2.structure == arg1) 
                {
                    if (loc2.level > loc1) 
                    {
                        loc1 = loc2.level;
                    }
                }
                ++loc3;
            }
            return loc1;
        }

        public getWarehouseCapacity(arg1: int): int
        {
            var loc1=0;
            var loc2=this.getInfoByType(EGuildStructureType._EGuildWareHouse, arg1);
            if (loc2) 
            {
                loc1 = loc2.effect;
            }
            return loc1;
        }

        public static get instance(): GuildStructureConfig
        {
            if (GuildStructureConfig._instance == null) 
            {
                GuildStructureConfig._instance = new GuildStructureConfig();
            }
            return GuildStructureConfig._instance;
        }

        /* internal */ /* var */_map: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_configArray: Array<any>;

        /* internal */ static /* var */_instance: GuildStructureConfig;
    }
